home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-10-05 | 5.6 KB | 277 lines | [TEXT/MMCC] |
- // CAMReminderDoc.cp -- Document methods
- // Created 10/5/95 4:49 PM by AppMaker
-
- #include "CAMReminderDoc.h"
-
- #include "CAMReminderData.h"
- #include "CMainWindow.h"
- #include "CmdCodes.h"
- #include "CAdd.h"
-
- #include <LFile.h>
- #include <LPlaceHolder.h>
- #include <LPrintout.h>
- #include <LWindow.h>
- #include <UWindows.h>
- #include <String_Utils.h>
-
- const ResIDT prto_PrintView = 201;
- const ResIDT STRx_Untitled = 128;
-
- // ---------------------------------------------------------------------------
- // • CAMReminderDoc
- // ---------------------------------------------------------------------------
-
- CAMReminderDoc::CAMReminderDoc(
- LCommander *inSuper)
- : LSingleDoc(inSuper)
- {
- mData = new CAMReminderData();
- }
-
- // ---------------------------------------------------------------------------
- // • ~CAMReminderDoc
- // ---------------------------------------------------------------------------
- // Destructor
- //
-
- CAMReminderDoc::~CAMReminderDoc()
- {
- delete mData;
- }
-
- //----------
- void
- CAMReminderDoc::newFile()
- {
- mData->newData();
-
- MakeWindows();
-
- NameNewDoc(); // Set name of untitled window
- }
-
- //----------
- void
- CAMReminderDoc::openFile(
- FSSpec *inFileSpec)
- {
- mData->openData (inFileSpec);
-
- MakeWindows();
-
- if (mWindow != nil) {
- mWindow->SetDescriptor (inFileSpec->name);
- }
- mIsSpecified = true;
- }
-
- // ---------------------------------------------------------------------------
- // • MakeWindows
- // ---------------------------------------------------------------------------
-
- void
- CAMReminderDoc::MakeWindows()
- {
- mMainWindow = CMainWindow::CreateMainWindow(this, mData);
-
- mWindow = mMainWindow;
- }
-
- // ---------------------------------------------------------------------------
- // • NameNewDoc
- // ---------------------------------------------------------------------------
- // Name a new, untitled document window
- //
- // Untitled windows start with "untitled", then "untitled 1",
- // "untitled 2", etc. Old numbers are reused, so there won't be
- // gaps in the numbering.
- //
- // This routine uses a STR# resource to store the "untitled" string,
- // which can be localized to different languages. The first string
- // is "untitled" and the second is "untitled " (trailing space),
- // which is used when appending a number to the name.
-
- void
- CAMReminderDoc::NameNewDoc()
- {
- // Start with the default name("untitled")
- Str255 name;
- ::GetIndString(name, STRx_Untitled, 1);
-
- long num = 0;
- while (UWindows::FindNamedWindow(name) != nil) {
-
- // An existing window has the current name
- // Increment counter and try again
-
- ::GetIndString(name, STRx_Untitled, 2);
- num++;
- Str15 numStr;
- ::NumToString(num, numStr);
- ConcatPStr(name, numStr);
- }
-
- mWindow->SetDescriptor(name); // Finally, set window title
- }
-
- // ---------------------------------------------------------------------------
- // • IsModified
- // ---------------------------------------------------------------------------
- // Return whether the Document has changed since the last save
-
- Boolean
- CAMReminderDoc::IsModified()
- {
- mIsModified = mData->IsDirty();
-
- return mIsModified;
- }
-
- // ---------------------------------------------------------------------------
- // • DoAESave
- // ---------------------------------------------------------------------------
- // Save Document in the specified file with the specified file type
- //
- // If file type is fileType_Default, use the normal file type for
- // this document
-
- void
- CAMReminderDoc::DoAESave(
- FSSpec &inFileSpec,
- OSType inFileType)
- {
- mData->DoSaveAs(&inFileSpec); // Write out data
- // Change window name
- mWindow->SetDescriptor(inFileSpec.name);
- }
-
- //----------
- void
- CAMReminderDoc::DoSave()
- {
- mData->DoSave();
- }
-
- //----------
- void
- CAMReminderDoc::DoRevert()
- {
- mData->DoRevert();
- }
-
- // ---------------------------------------------------------------------------
- // • DoPrint
- // ---------------------------------------------------------------------------
- // Print the contents of the Document
-
- void
- CAMReminderDoc::DoPrint()
- {
- LPrintout *thePrintout = LPrintout::CreatePrintout(prto_PrintView);
- LPlaceHolder *textPlace = (LPlaceHolder *)
- thePrintout->FindPaneByID('TBox');
- //! textPlace->InstallOccupant(mTextView, atNone);
-
-
- thePrintout->DoPrintJob();
- delete thePrintout;
- }
-
- //----------
- void
- CAMReminderDoc::DoAddReminder ()
- {
- CAdd* dialog = CAdd::CreateAdd(this);
- }
-
- //----------
- void
- CAMReminderDoc::DoEditReminder ()
- {
- CAdd* dialog = CAdd::CreateAdd(this);
- }
-
- //----------
- void
- CAMReminderDoc::DoDeleteReminder ()
- {
- }
-
- //----------
- void
- CAMReminderDoc::ObeyAdd (void* ioParam)
- {
- }
-
- //----------
- Boolean
- CAMReminderDoc::ObeyCommand(
- CommandT inCommand,
- void *ioParam)
- {
- Boolean cmdHandled = true;
-
- switch (inCommand) {
-
- // +++ Add cases here for the commands you handle
- // Remember to add same cases to FindCommandStatus below
- // to enable/disable the menu items for the commands
-
-
- case cmdAddReminder:
- DoAddReminder ();
- break;
-
- case cmdEditReminder:
- DoEditReminder ();
- break;
-
- case cmdDeleteReminder:
- DoDeleteReminder ();
- break;
-
- case cmd_Add:
- ObeyAdd (ioParam);
- break;
-
- default:
- cmdHandled = LSingleDoc::ObeyCommand(inCommand, ioParam);
- break;
- }
-
- return cmdHandled;
- }
-
- //----------
- void
- CAMReminderDoc::FindCommandStatus(
- CommandT inCommand,
- Boolean &outEnabled,
- Boolean &outUsesMark,
- Char16 &outMark,
- Str255 outName)
- {
- outUsesMark = false;
-
- switch (inCommand) {
-
- // +++ Add cases here for the commands you handle
-
- case cmdAddReminder:
- outEnabled = true;
- break;
- case cmdEditReminder:
- outEnabled = true;
- break;
- case cmdDeleteReminder:
- outEnabled = true;
- break;
-
- default:
- LSingleDoc::FindCommandStatus(inCommand, outEnabled,
- outUsesMark, outMark, outName);
- break;
- }
- }
-